package com.richman.ps38;

import com.richman.controller.DaShui;

public class PS38GrabThread extends Thread {

	
	public long sleepTime = 30*1000;
	PS38Manager ps38Manager = null;
	
	boolean start = false;
	boolean loginNow = false;
	
	boolean bexit = false;
	
	public static Long refreshTime = System.currentTimeMillis();

	public PS38GrabThread(PS38Manager ps38ManagerArg){
		ps38Manager = ps38ManagerArg;		
	}
	
	
	public boolean getbexit() {
		return bexit;
	}
	
	@Override
    public void run() {
		

		try{

			while(DaShui.bStartEngine){
				try{
					ps38Manager.login();
					ps38Manager.grabEvents();
					ps38Manager.getBalance();
					refreshTime = System.currentTimeMillis();
					
					
				}catch(Exception e){
					e.printStackTrace();
					Thread.sleep(2000);
				}
				

			}
			
			PS38Manager.ps38Events.clear();
			
			DaShui.mainWnd.updatePS38EventsTable(PS38Manager.ps38Events);
			
			bexit = true;

		}catch(Exception e){
			e.printStackTrace();
		}	
	}
	
}
